<div class="card-factory">
    <div class="nav">
        <div class="nav-li focus">会员卡</div>
    </div>
    <hr />

    <div class="infobox">
        <div class="card-factory-new">
            <h4>新增会员卡 
            {{#if $Cache.bus.card_factory.new._id}}
            <button event-click="{{'$Event.bus.card_factory.update_card_factory'}}">确定修改</button> 
            <button event-click="{{'$Event.bus.card_factory.cancel_update'}}">取消修改</button> 
            {{#else}}
            <button event-click="{{'$Event.bus.card_factory.add_card_factory'}}">确定添加</button> 
            {{/if}}
            </h4>
            <table class="paper-table">
            	<thead>
            		<td style="width:33.33%">基础信息</td>
            		<td style="width:33.33%">优惠配置</td>
                <td style="width:33.33%">高级配置</td>
            	</thead>
            	<tr>
            		<td>
                		<android:input bind-input="{{'$Cache.bus.card_factory.new.info.name'}}" value="{{$Cache.bus.card_factory.new.info.name}}" label="会员卡名称"></android:input>
                		<android:input bind-input="{{'$Cache.bus.card_factory.new.info.card_list_limit'}}" value="{{#IsInfinity $Cache.bus.card_factory.new.info.card_list_limit,'无限制'}}" label="发行张数限制" description="如果为0或者放空，则意味着不限制发行张数"></android:input>
                    <div>过期时间：<android:datePicker value="{{#if $Cache.bus.card_factory.new.info.diedline}}{{#Time $Cache.bus.card_factory.new.info.diedline,'YYYY-MM-DD'}}{{#else}}未设置（永不过期）{{/if}}" bind-input="{{'$Cache.bus.card_factory.new.info.diedline'}}"></android:datePicker></div>

            		</td>
            		<td>
						<div>优惠类型：
<android:selectSearch use-value-as-result="true" value="{{$Cache.bus.card_factory.new.info.type}}" placeholder="请选择会员卡类型" bind-input="{{'$Cache.bus.card_factory.new.info.type'}}">
    {{#each $Top.$Cache.CARD_FACTORY_TYPE_array}}
    <optionItem value="{{value}}" search-data="{{value+key}}">{{key}}</optionItem>
    {{/each}}
</android:selectSearch>
{{#if $Cache.bus.card_factory.new.info.type==config.CARD_FACTORY_TYPE.满减}}
	<div>满减配置：
	<android:input bind-input="{{'$Cache.bus.card_factory.new.info.config.full_cash'}}" value="{{$Cache.bus.card_factory.new.info.config.full_cash}}" label="满" description="订单满多少金额"></android:input>
	<android:input bind-input="{{'$Cache.bus.card_factory.new.info.config.cut_cash'}}" value="{{$Cache.bus.card_factory.new.info.config.cut_cash}}" label="减" description="减免多少金额"></android:input>
	</div>
{{/if}}
{{#if $Cache.bus.card_factory.new.info.type==config.CARD_FACTORY_TYPE.打折}}
	<div>折扣配置：（100元减免{{#Fixed 100*$Cache.bus.card_factory.new.info.config.discount}}元）
	<inputnumber bind-input="{{'$Cache.bus.card_factory.new.info.config.discount'}}" value="{{$Cache.bus.card_factory.new.info.config.discount}}" loop="0.01" min="0" max="1" fixed="4"></inputnumber>
	</div>
{{/if}}
{{#if $Cache.bus.card_factory.new.info.type==config.CARD_FACTORY_TYPE.现金抵用}}
	<android:input bind-input="{{'$Cache.bus.card_factory.new.info.config.directly_cut_cash'}}" value="{{$Cache.bus.card_factory.new.info.config.directly_cut_cash}}" label="直接抵扣金额"></android:input>
{{/if}}
						</div>
            		</td>
                <td>
                  <div>
                    是否需要通过购买获得：<android:switch bind-input="{{'$Cache.bus.card_factory.new.info.need_buy'}}" checked="{{$Cache.bus.card_factory.new.info.need_buy}}">{{$Cache.bus.card_factory.new.info.need_buy?'购买模式':'领取模式'}}</android:switch>
                    {{#if $Cache.bus.card_factory.new.info.need_buy}}
                    <android:input label="价格" value="{{$Cache.bus.card_factory.new.info.need_buy_price}}" bind-input="{{'$Cache.bus.card_factory.new.info.need_buy_price'}}"></android:input>
                    <android:input label="返现" description="所反现金会直接进入用户账户上，在购买其它商品的时候进行抵扣" value="{{$Cache.bus.card_factory.new.info.need_buy_back_cash}}" bind-input="{{'$Cache.bus.card_factory.new.info.need_buy_back_cash'}}"></android:input>
                    {{/if}}
                  </div>
                </td>
            	</tr>
            </table>
        </div>

        <div class="card-factory-list">
            <h4>现有会员卡</h4>
          	<table class="paper-table">
          		<thead>
          			<td>序号</td>
          			<td>名称</td>
          			<td>描述</td>
          			<td>操作</td>
          		</thead>
          		{{#each $Cache.bus.card_factory.list}}
          		<tr>
          			<td>{{$Index+1}}</td>
          			<td>{{info.name}} <android:icon hidden="{{!info.need_buy}}" type="action-credit-card" color="#888700"></android:icon><copybutton value="{{_id}}">复制ID</copybutton></td>
          			<td>{{info.intro}}</td>
          			<td>
                  <button event-click="{{'$App.$Event.bus.card_factory.to_update'}}">修改</button>
                  <button event-click="{{'$App.$Event.bus.card_factory.remove_card_factory'}}">删除</button>
                  </td>
          		</tr>
          		{{/each}}
          	</table>
        </div>
    </div>
</div>
<style>
.card-factory .card-factory-new .paper-table tr td{
  vertical-align: top;
  padding: 8px 12px;
}
</style>